<html>
<head>
<title>Converting Strings to Numbers</title>
</head>
<body>
<table width=100%>
<tr>
<td align=left>
<a href="conversion.html"><img src=../../images/PreviousArrow.gif width=26 height=26 align=bottom border=0 alt="Previous | "></a><a
href="stringsAndJavac.html"><img src=../../images/NextArrow.gif width=26 height=26 align=bottom border=0 alt="Next | "></a><a
href="../../index.html"><img src=../../images/WayUpArrow.gif width=26 height=26 align=bottom border=0 alt="Trail Map | "></a><a
href="../index.html"><img src=../../images/javaHeader.gif width=26 height=26 align=bottom border=0 alt="Writing Java Programs | "></a>
<td>
<td align=right>
<a href="index.html"><strong><em>The String and StringBuffer Classes</em></strong></a>
</td>
</tr>
</table>
<p>
<hr size=4>

<h2>
    Converting Strings to Numbers
</h2>
<p>
<blockquote>

The String class itself does not provide any methods for converting a String
to a floating point, integer, or other numerical type. However,
four of the "type wrapper" classes (Integer, Double, Float and Long)
provide a method named <code>valueOf()</code> that converts a String
to that type. Here's a small, contrived example of the Float class's
<code>valueOf()</code>.
<blockquote>
<pre>
String piStr = "3.14159";
Float pi = Float.valueOf(piStr);
</pre>
</blockquote>
<code>valueOf()</code> is a static method.

</blockquote>
<p>
<hr size=4>
<p>
<table width=100%>
<tr>
<td align=left>
<a href="conversion.html"><img src=../../images/PreviousArrow.gif width=26 height=26 align=top border=0 alt="Previous | "></a><a
href="stringsAndJavac.html"><img src=../../images/NextArrow.gif width=26 height=26 align=top border=0 alt="Next | "></a><a
href="../../index.html"><img src=../../images/WayUpArrow.gif width=26 height=26 align=top border=0 alt="Trail Map | "></a><a
href="../index.html"><img src=../../images/javaHeader.gif width=26 height=26 align=top border=0 alt="Writing Java Programs | "></a>
<td>
<td align=right>
<a href="index.html"><strong><em>The String and StringBuffer Classes</em></strong></a>
</td>
</tr>
</table>
</body>
</html>
